
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zzq.util.QRCodeUtil;
import net.coobird.thumbnailator.Thumbnails;
import net.coobird.thumbnailator.geometry.Positions;
import org.junit.jupiter.api.Test;

import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;


public class CodeGenerator {


    @Test
    public void Test() throws IOException {

        Thumbnails.of(new File("C:\\Users\\Administrator\\Pictures\\X2-end-2.jpg"))
                .watermark(Positions.BOTTOM_RIGHT, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.BOTTOM_CENTER, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.BOTTOM_LEFT, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.CENTER, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.CENTER_LEFT, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.CENTER_RIGHT, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.TOP_CENTER, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.TOP_RIGHT, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .watermark(Positions.TOP_LEFT, ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\watermark.png")), 1f)
                .size(3840, 2160)
                .toFile(new File("image-with-watermark2.jpg"));

    }

    @Test
    public void test() {
        HashMap<String, Object> map = new HashMap();
        map.put("api_key", "80783e2e418e490a986935d1464f3d06");
        map.put("api_secret", "b1edb98580c7414cb3c54c89f4b00411");
        map.put("media_code", "MTyunxiu17a8062f33");
        map.put("media_data", "https://beauty-public.zone1.meitudata.com/Marvel/1680141903114.jpg");
        map.put("repost_url", "");
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("api_key", "80783e2e418e490a986935d1464f3d06");
        jsonObject.put("api_secret", "b1edb98580c7414cb3c54c89f4b00411");
        jsonObject.put("media_code", "MTyunxiu17a8062f33");
        jsonObject.put("media_data", "http://zzqjt.oss-cn-hangzhou.aliyuncs.com/templates/client/test/97f59d942060473090d76385989fcfdd-test2.jpg");
        jsonObject.put("repost_url", "http://zhongyeyl.cn/job/");


        String string = HttpUtil.createPost("https://api.yunxiu.meitu.com/openapi/realphotolocal_async")
                .header("content-type","application/json").body(jsonObject.toString()).execute().body();
        System.out.println(string);
    }

    @Test
    public void test2() {
        JSONObject jsonObject=new JSONObject();
        jsonObject.put("api_key", "80783e2e418e490a986935d1464f3d06");
        jsonObject.put("api_secret", "b1edb98580c7414cb3c54c89f4b00411");
        jsonObject.put("msg_id", "ba340b27-0664-44db-b3db-fd912c41bab9");


        String string = HttpUtil.createPost("https://api.yunxiu.meitu.com/openapi/query")
                .header("content-type","application/json").body(jsonObject.toString()).execute().body();
        System.out.println(string);
    }
    @Test
    public void test3() throws Exception {
        String rQjson = QRCodeUtil.getRQjson("https://www.baidu.com/");
        System.out.println(rQjson);
    }
}
